package cn.elegent.txdemo.user.handler;


import cn.elegent.ac.ACHandler;
import cn.elegent.ac.annotation.Topic;

import cn.elegent.txdemo.common.dto.PayDto;
import cn.elegent.txdemo.user.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * 用户微服务接收消息
 */
@Topic("cut_money")
@Slf4j
public class UserHandler implements ACHandler<PayDto> {

    @Autowired
    private UserService userService;

    @Override
    public void process(String topic,PayDto payDto) throws Exception {
        log.info("收到了消息来自："+topic+",数据："+payDto);
        //扣除账户余额
        userService.deduct( payDto);
    }
}
